# -*- coding: utf-8 -*-
"""
-------------------------------------------------
Project Name: luffcity study project
File Name: school_data.py
Author: kij
Create Date: 2021/2/19
-------------------------------------------------
"""

import os
import pickle
from conf.config import BASE_DIR, ROLE_TUPLE

class School:
	"""
	机构相关类，机构名称和机构地址
	"""
	lessons = []
	teachers = []
	students = []

	def __init__(self, org_name, org_address,admin_name):
		self.admin_name = admin_name
		self.org_name = org_name
		self.org_address = org_address

	@classmethod
	def get_school(cls,admin_name):
		file_path = os.path.join(BASE_DIR, "files", "org_list.pkl")
		org_list = []
		with open(file_path, mode='rb') as org_file:
			while True:
				try:
					org = pickle.load(org_file)
					if org.admin_name == admin_name:
						org_list.append(org)
				except EOFError:
					break
		return org_list

	def add_lesson(self, lesson):
		self.lessons.append(lesson)

	def add_teacher(self, teacher):
		self.lessons.append(teacher)

	def add_student(self, student):
		self.lessons.append(student)



# 班级名称
class SchoolClass:
	"""
	学校班级名称，老师和学生。
	"""

	teachers = []
	def __init__(self, cla_name, cla_time=None, cla_price=None):
		self.cla_name = cla_name
		self.cla_time = cla_time
		self.cla_price = cla_price

	def add_student(self, student):
		print('新增学生')
		self.students.append(student)

	def add_teacher(self, teacher):
		print('新增老师')
		self.teachers.append(teacher)
